<template>
  <!-- 密码 -->
  <u-popup v-model="show" mode="center" border-radius="14">
    <div class="pup">
      <view class="title u-font-30 u-flex u-col-center u-row-between">
        <text class="p0">支付</text>
        <u-icon name="close" color="#aaa" size="26" @click="show = false"></u-icon>
      </view>
     <!-- // const data = {
      //   house_sn: this.con.houseSn,
      //   start_date:this.con.tenancy_start_time,
      //   end_date:this.con.tenancy_end_time,
      //   type_id:this.con.type_id, // 1按月，2-按天
      //   month_number:this.con.month_number, // 月数
      //   ordersNo:this.con.tenancy_order_sn,
      //   orderFee: this.con.tenancy_price, // 总价
      //   house_title: this.con.house_title, // 标题
      // } -->
      <view class="p p1">
        <view class="lab">
          <text>房</text>
          <text>源：</text>
        </view>
        {{info.house_title}}
      </view>
      <view class="p">
        <view class="lab">
          <text>租</text>
          <text>赁</text>
          <text>方</text>
          <text>式：</text>
        </view>
        {{info.type_id ==1 ? '按月' : '按天'}}
      </view>
      <view class="p" v-if="info.type_id ==1">
        <view class="lab">
          <text>租</text>
          <text>赁</text>
          <text>月</text>
          <text>数：</text>
        </view>
        {{info.month_number}}
      </view>
      <view class="p">
        <view class="lab">
          <text>租</text>
          <text>赁</text>
          <text>日</text>
          <text>期：</text>
        </view>
        {{info.start_date}}~{{info.end_date}}
      </view>
      <view class="p">
        <view class="lab">
          <text>租</text>
          <text>赁</text>
          <text>金</text>
          <text>额：</text>
        </view>
        {{info.orderFee}}元
      </view>
      <view class="p">
        <view class="lab">
          <text>房</text>
          <text>屋</text>
          <text>押</text>
          <text>金：</text>
        </view>
        {{info.house_deposit}}元
      </view>
      <view class="p">
        <view class="lab">
          <text>方</text>
          <text>式：</text>
        </view>
        {{info.payment_method_type_name}}
      </view>
      <u-button type="primary" class="call-btn u-font-30" @click="submit">立即支付</u-button>
    </div>
  </u-popup>
  
</template>

<script>
  export default {
    name:"zb-jiaofei",
    props: {
      money: {
        default: '0'
      },
      top: {
        default: '0'
      },
    },
    data() {
      return {
        show:false,
        password:'',
        info:null
      };
    },
    methods:{
      showFun(datas){
        this.show = true;
        this.info = datas
        
      },
      submit(){
        this.$api.payOrderApi({ordersNo: this.info.ordersNo}).then( res =>{
          if(res.code === 1){
            uni.requestPayment({
            	provider: 'wxpay',
            	timeStamp: res.data.timeStamp,
            	nonceStr: res.data.nonceStr,
            	package: res.data.package,
            	signType: res.data.signType,
            	paySign: res.data.paySign,
            	success: rest => {
            		this.$u.toast('支付成功！');
                this.show = false;
                if(this.info.link === 1){
                  uni.reLaunch({
                    url:"/hotel/order/order?type=4"
                  })
                }else{
                  this.$emit('ok')
                }
            	},
            	fail: err => {
            		if (err.errMsg == "requestPayment:fail cancel") {
            		  this.$u.toast('支付已取消');
            		}else{
            		  this.$u.toast('错误：' + err.errMsg)
            		}
            	}
            });
          }else{
            this.$u.toast(res.msg);
          }
        })
      },
    }
  }
</script>

<style lang="scss" scoped>
.pup{
  padding: 0 30rpx 40rpx; width:690rpx; box-sizing: border-box;
  .title{font-size: 30rpx; height: 90rpx; border-bottom: 1px solid #ededed; margin: 0 -30rpx 20rpx; padding: 0 30rpx;}
  .p0{font-size: 30rpx; color: #000;}
  .p{font-size: 28rpx; margin-bottom: 16rpx; display: flex;}
  .lab{color: #666; width: 160rpx; padding-right:10rpx; display: flex; font-size: 28rpx; justify-content: space-between;}
  .w{width: 50rpx; height: 2rpx;}
  .call-btn{margin-top: 40rpx; display: block;}
}
</style>